<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width">
    <title>Basic document flow</title>


    <!-- 定位：比浮动更精确控制元素出现在哪里 -->
    <style>
      body {
        width: 500px;
        margin: 0 auto;
      }

      p {
        background: aqua;
        border: 3px solid blue;
        padding: 10px;
        margin: 10px;
      }

      span {
        background: red;
        border: 1px solid black;
      }

      .positioned {
        /* position: static;  位置默认值 */

        /* 相对定位: 原来元素的占位还在，只是新位置基于原来位置偏移 */
        /* position: relative; */
        top: 300px;
        left: 50px;

        /* 绝对定位：原来元素的占位不在（脱离文档流）；
        新位置基于整个文档开始位置重新算 */
        position: absolute;
      }
    </style>
  </head>
  <body>
    <h1>Basic document flow</h1>
    <p>I am a basic block level element. My adjacent block level elements sit on new lines below me.</p>
    <p class="positioned">By default we span 100% of the width of our parent element, and our height is as tall as our child content. Our total width and height is our content + padding + border width/height.</p>
    <p>We are separated by our margins. Because of margin collapsing, we are separated by the width of one of our margins, not both.</p>
    <p>inline elements <span>like this one</span> and <span>this one</span> sit on the same line as one another, and adjacent text nodes, if there is space on the same line. Overflowing inline elements <span>wrap onto a new line if possible — like this one containing text</span>, or just go on to a new line if not, much like this image will do: </p>
  </body>
</html>
